<?php
class Application_Model_Filter_GeneralizeSearch {
    /**
     * 快速搜索
     */
    public $quick;  
    /**
     * 时间类型
     */
    public $timescope;
     /**
     * 开始时间
     */
    public $startTime;
    /**
     * 结束时间
     */
    public $endTime;
    /**
     * 类型
     */
    public $type;
    /**
     * 状态
     */
    public $status;
    
    function getSearchFileds() {
        $where=array(); 
        $and = "";
        if($this->quick != ""){
            $where["( name like "] = "%".  $this->quick . "%";
            $where[" or content like "] = "%".  $this->quick . "%";
            $where[" ) and 1 = "] = 1;
            $and = " and ";
        }
        
        if($this->startTime != ""){
            if($this->timescope != ""){
                $where[$and.$this->timescope." > "] = $this->startTime;
            } else {
                $where[$and." createdTime > "] = $this->startTime;
            }
            $and = " and ";
        }
        
        if($this->endTime != ""){
            if($this->timescope != ""){
                $where[$and.$this->timescope." <= "] = $this->endTime." 23:59:59";
            } else {
                $where[$and." createdTime <= "] = $this->endTime." 23:59:59";
            }
            $and = " and ";
        }
        
        if($this->cityId != ""){
            $where[$and." cityId = "] = $this->cityId;
            $and = " and ";
        }
        
        if($this->status != ""){
            $where[$and." status = "] = $this->status;
            $and = " and ";
        }
        
        return $where;
    }
    
}

